<?php /* sample2 */
error_reporting(0);
?>
<?php
if(isset($_POST['calculate'])){
$firstnumber = $_POST['firstnumber'];
$secondnumber = $_POST['secondnumber'];
$number1;
$number;
$numbersum;
$numbersum1;
$counter=0;
$counter1=0;
for($i=$firstnumber;$i<=$secondnumber;$i++)
{
if($i % 2 == 0) {
		$number.=$i.'<br>';
		$numbersum=$i+$numbersum;
		$counter++;
		}
	else{
		$number1.=$i.'<br>';
		$numbersum1=$i+$numbersum1;
		$counter1++;
		}
}
}

?>

<form action="sample2.php" method="post">
<span>From</span>
<input type="text" name="firstnumber" value="" />
<span>To</span>
<input type="text" name="secondnumber" value="" />
<input type="submit" name="calculate" value="Show Output" />
</form>

<?php

if(isset($_POST['calculate'])){
echo "List of Even Numbers";
echo $number.'<br>';

echo "List of odd Numbers";
echo $number1.'<br>';

echo "Sum of all Even Numbers";
echo $numbersum.'<br>';

echo "Sum of all odd Numbers";
echo $numbersum1.'<br>';

echo $counter;
echo $counter1;
}
?>
